function isNumeric(value) {
  if (value == null || !value.toString().match(/^[-]?\d*\.?\d*$/)) 
  	return false;
  else {
  	return true;
  }
}

$(function() {
		   
    $('.editTaskUser').editable('/tasksUsers/updateTaskUser', {
         id   : 'data[TasksUser][id]',
         name : 'data[TasksUser][estimateHours]',
         submit    : 'Save',
		 cancel		: 'Cancel',
         tooltip   : 'Click to edit the hours',
		 width	: '50',
		 onsubmit: function(settings, td) {
					var input = $(td).find('input');
					var original = input.val();
					if (isNumeric(original)) {
						return true;
					} else {
						alert("Numeric input only!");
						return false;
					}
   				 }
    });
	
	$('.editResourceEstimate').editable('/projects_resources/updateResourceEstimate', {
         id   : 'data[ProjectsResource][id]',
         name : 'data[ProjectsResource][estimate]',
         submit    : 'Save',
		 cancel		: 'Cancel',
         tooltip   : 'Click to edit the units',
		 width	: '50',
		 onsubmit: function(settings, td) {
					var input = $(td).find('input');
					var original = input.val();
					if (isNumeric(original)) {
						return true;
					} else {
						alert("Require numeric input.");
						return false;
					}
   				 }
    });
	
	$('.editResourceActual').editable('/projects_resources/updateResourceActual', {
         id   : 'data[ProjectsResource][id]',
         name : 'data[ProjectsResource][actual]',
         submit    : 'Save',
		 cancel		: 'Cancel',
         tooltip   : 'Click to edit the units',
		 width	: '50',
		 onsubmit: function(settings, td) {
					var input = $(td).find('input');
					var original = input.val();
					if (isNumeric(original)) {
						return true;
					} else {
						alert("Numeric input only!");
						return false;
					}
   				 }
    });
	
	
	$('.editBillHours').editable('/timesheets/updateBillHours', {
         id   : 'data[Timesheet][id]',
         name : 'data[Timesheet][billHours]',
         submit    : 'Save',
		 cancel		: 'Cancel',
         tooltip   : 'Click to edit the units',
		 width	: '50',
		 onsubmit: function(settings, td) {
					var input = $(td).find('input');
					var original = input.val();
					if (isNumeric(original)) {
						return true;
					} else {
						alert("Numeric input only!");
						return false;
					}
   				 }
    });	
	
	
	$('.editNonBillHours').editable('/timesheets/updateNonBillHours', {
         id   : 'data[Timesheet][id]',
         name : 'data[Timesheet][nonBillHours]',
         submit    : 'Save',
		cancel		: 'Cancel',
         tooltip   : 'Click to edit the units',
		 width	: '50',
		 onsubmit: function(settings, td) {
					var input = $(td).find('input');
					var original = input.val();
					if (isNumeric(original)) {
						return true;
					} else {
						alert("Numeric input only!");
						return false;
					}
   				 }
    });		
	
	
});



